<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<meta name="copyright" content="http://www.appcms.org" />
<link rel="stylesheet" type="text/css" href="skin/picture_show.css">
<script src="js/zy_control.js"></script>
<script src="js/zy_click.js"></script>
<script src="js/zy_slide.js"></script>
<script src="js/config.js"></script>
</head>
<body ontouchstart>
<div id="main">
	<header id="header">
		<span class="l" id="back" ontouchstart="zy_touch('act')" onclick="uexWindow.close(-1);"></span>
    	<h1 id="title" >图片浏览</h1>
    	<span class="r" ontouchstart="zy_touch('down')" onclick="imageBrowser();"></span> 
	</header>
	
	<section id="photos" ontouchstart="zy_touch('')" onclick="isHide()">
    	<div id="status"></div>
	</section>
	
	<footer>
    	<pre id="brief"></pre>
	</footer>
</div>
</body>
<script>
zy_init();
var Show='',
	id=localStorage['picture_id'],
	title='',
	briefs=[],
	length=0,
	i=0,
	inStatus=1,
	imgs,
	activeIndex;
function close(){
	var t = event.currentTarget;
	if(Show!="") return;
	if(checkActive(t)) return;
	uexWindow.close(-1);
}
function isHide(){
	if(inStatus) return;
	Show=(Show=="")?'hide':'';
	$$('main').className=Show;
}
function imgLoadSuc(id, src){
	if (typeof(src) == 'string') {		
		var e = $$(id);
		if(e){
			e.src = src;
			e.className='';
		}
	}
}

function setBrief(i){
	activeIndex = i;
	var brief='（'+(i+1)+'/'+length+'）'+title;
	if(briefs[i]) brief+="\n"+briefs[i];
	$$('brief').innerHTML=brief;
}

function getItem(){
	var url= app_api+'&a=show&id='+localStorage['picture_id']+'&catid='+localStorage['picture_catid'];
	uexXmlHttpMgr.open(1,'get',url,"8000");
	uexXmlHttpMgr.send(1);
}

function getData(){
	
	$$('status').innerHTML='<div class="loading"></div>';
	getItem();
}
function removeNode(id){
	var e = $$(id);
	if(e) e.parentElement.removeChild(e);
}

function imageBrowser(){
	uexImageBrowser.open(imgs,activeIndex,1);
}


window.uexOnload = function(type){
	if (!type) {
		if (typeof(localStorage['add20head'])== "1") {
			$$('header').style.paddingTop='20px';
		}
		
		
		uexXmlHttpMgr.onData = function(opId, status, data){
			if(status==1){
				uexXmlHttpMgr.close(opId);
				data = JSON.parse(data).data;
				
				if(data){
					imgs=data.pictureurls;
					var Html='';
					length=imgs.length;
					title=data.title;
					briefs=data.picturetitles;
					for (var i in imgs) {
						var imgarr = [imgs[i]];
						Html+='<div class="loadimg" ondblclick="imageBrowser('+i+');"><img src="'+imgs[i]+'" class="hide" onload="this.className=\'\'"></div>';
					}

					$$('photos').innerHTML=Html;
					setBrief(0);
					
					$$('photos').slide=new zySlide(
						'photos',
						'H',
						function(){
							if(this.direction<0 && i==0){						
								//uexWindow.close(-1);
							}
						},
						false,
						function(e){
							i=this.currentPoint;
							setBrief(i);
						}
					);
					inStatus=0;
					$$('status').style.opacity = 0;
					window.setTimeout(function(){
						removeNode('status');
					}, 1000);
				}else{
					uexWindow.cbConfirm = function(opId,dataType,data){
						uexWindow.close(-1);
					}
					uexWindow.confirm('','您查看的图集存不在！',['返回']);
				}
				
			}else if(status ==-1) {
				uexWindow.toast("0","5",'加载失败',1000);
			}
		}
		
		getData();
    }
}
</script>
</html>